#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* longestCommonPrefix(char** strs, int strsSize)
{
    char *ptr = malloc(sizeof(char)*strlen(strs[0]));
    memset(ptr,0,strlen(strs[0]));
    strcpy(ptr,strs[0]);
    for(int i = 0;ptr[i] != '\0';i++)
    {
        for(int j = 0;j < strsSize;j++)
        {
            if(ptr[i] != strs[j][i])
            {
                ptr[i] = '\0';
                return ptr;
            }
        }
    }
    return ptr;
}

int main()
{
    char *ptr[3] = {"flowe","flow","flight"};
    char * str = longestCommonPrefix(ptr,sizeof(ptr)/sizeof(ptr[0]));
    printf("%s\n",str);
    free(str);
    str = NULL;

    return 0;
}